#include <iostream>
#include <string>
#include <cstdio>

using namespace std;

int emonth[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
char week_name[][6] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
char month_name[][10] = {"January", "February", "March", "April", "May", "June","July", "August", "September", "October", "November", "December"};

int IsLeap(int year) {
	if(year%400==0 || year%4==0 && year%100==0) {
		emonth[1] = 29;
		return 1;
	} else
		return 0;
}

int main(int argc, char * argv[]) {
	int year, month, day;

	while(cin >> year) {
		// 判断这一年的第一天是星期几
		int first_day_of_year = (year + (year-1)/4 - (year-1)/100 + (year-1)/400) % 7;

		// 月份
		for(int m=0; m<12; m++) {
			
			printf("%s\n\n", month_name[m]);

			// 星期
			for(int w=0; w<7; w++) {
				printf("%6s", week_name[w]);
			}
			printf("\n\n");

			// 排到first_day_of_year
			for(int i=0; i<first_day_of_year; i++) {
				printf("%6s", " ");
			}

			// 每个月的长度
			for(int e=1; e<=emonth[m]; e++) {
				if( first_day_of_year % 7 == 0) {
					first_day_of_year %= 7;
					printf("\n");	
				}
				first_day_of_year ++;
				printf("%6d", e);
			}

			printf("\n=========================================================\n");
		}
	}
	return 0;
}
